DataViews table layout: hide actions menu when there is only one action and is primary#67020
DataViews table layout: hide actions menu when there is only one action and is primary#67020
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| primaryActions: Action< Item >[], | ||
| actions: Action< Item >[] | ||
| ) { | ||
| return primaryActions.length === 1 && actions.length; |
There was a problem hiding this comment.
Why not inline the check?
There was a problem hiding this comment.
That could work as well. No big feelings either way. I suppose I thought it better to have it explain the why.
|
Noting that we do this for every layout and not only for I was a bit confused that |
This is actually only for the table. Here's the PR for the list #67015 :) The list view uses the subcomponents directly to handle the keyboard interactions. The grid is unaffected because it uses the compact view (no primary actions visible). This can be tested by switching to any other layout during testing.
|
Exactly. If grid wasn't using the compact and had one primary action would have the same behavior. For now it doesn't, but when we open the API for registering layouts, this behavior will be for any layout. |
|
@ntsekouras Agreed. If things worked differently then yes, it'd make sense to change the changelog/issue title to be about all the layouts. I just worry that it'd be confusing to say so when it's not true right now? Not sure how it could be improved without being confusing, but happy to explore alternatives if you have any suggestion. |
|
The title is not that important right now, yes. We should keep this in mind when creating the API for layouts to document it. |
| primaryActions: Action< Item >[], | ||
| actions: Action< Item >[] | ||
| ) { | ||
| return primaryActions.length === 1 && actions.length; |
There was a problem hiding this comment.
@oandregal I believe the condition actions.length should be updated to actions.length === 1. The current implementation only displays the primary action when there is exactly one primary action, even if additional non-primary actions are present.
https://wordpress.github.io/gutenberg/?path=/story/dataviews-dataviews--default

gutenberg/packages/dataviews/src/components/dataviews/stories/fixtures.tsx
Lines 610 to 615 in b7d989e



Part of #65165
What?
This PR hides the actions menu for the DataViews table layout when there's only 1 action and is primary.
All current core screens have more than one action. See testing instructions below.
Why?
To improve UX.
Testing Instructions
This is something we've heard from extenders. Because there's no place in core where we have this situation just yet, we have to create one for testing:
postTypeActionsin this line and in the line below (in both arrays).